Component({
  //behaviors: [require('../../common/share-behavior').default],
  properties: {
    a: Number,
    videoImageUrl:String,
    videoUrl:String,
    modelImageUrl:String,
    modelUrl:String,
    scale:String,
    rotation:String,
    position:String

  },
  data: {
    loaded: false,
    arReady: false,
    planeScale: [16/9, 1, 1] 
  },
  lifetimes: {
    async attached() {
      console.log('data', this.data)
    }
  },
  methods: {
    handleReady({detail}) {
      const xrScene = this.scene = detail.value;
      this.mat = new (wx.getXrFrameSystem().Matrix4)();
      console.log('xr-scene', xrScene);
      console.log('xr-videoImageUrl',this.data.videoImageUrl)
    },
    handleAssetsProgress: function ({
      detail
    }) {
    },
    handleAssetsLoaded: function ({
      detail
    }) {
       console.log('assets loaded', detail.value);
      this.setData({
        loaded: true
      });
    },

    handleAnimationStop: function() {
      console.log('animation Stop');
    },
       handleARTrackerState1({detail}) {
        // 事件的值即为`ARTracker`实例
        const tracker = detail.value;
      
        // 获取当前状态和错误信息
        const {state, errorMessage} = tracker;
        // const video = this.scene.assets.getAsset('video-texture', 'hikari', 'white');
        console.log(state==2);
  
        if(state==2){
           console.log("识别", state);
          this.time1 = setTimeout(() => {
           this.setData({
             isShow: true,
           })
          }, 1000)
        }else{
          this.setData({
            isShow: false
          })
        }
  
      },
    handleARReady({detail}) {
      const xrFrameSystem = wx.getXrFrameSystem();
      const tracker = this.scene.getElementById('ar-tracker').getComponent(xrFrameSystem.ARTracker);
      // 初始状态
      const {state, errorMessage} = tracker;
      // 绑定事件
      tracker.el.event.add('ar-tracker-state', tracker => {
        const {state, errorMessage} = tracker;

      });
    },
    handleTrackerSwitch: function ({detail}) {
      const active = detail.value;
      console.log('handleTrackerSwitch', detail);
      //hikari为asset名称
      const video = this.scene.assets.getAsset('video-texture', 'hikari');
      if (active) {
        video.play();
      } else {
        video.stop();
      }
    },
     handleGLTFLoaded({detail}) {
      
  }
  
  }
})